//********************************************************************************************
//
// File : udp.h implement for User Datagram Protocol
//
//********************************************************************************************
//
// Copyright (C) 2007
//
// This program is free software; you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free Software
// Foundation; either version 2 of the License, or (at your option) any later
// version.
// This program is distributed in the hope that it will be useful, but
//
// WITHOUT ANY WARRANTY;
//
// without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
// PURPOSE. See the GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along with
// this program; if not, write to the Free Software Foundation, Inc., 51
// Franklin St, Fifth Floor, Boston, MA 02110, USA
//
// http://www.gnu.de/gpl-ger.html
//
//********************************************************************************************
#ifndef __UDP_h__
#define __UDP_h__

#include "BasicTypes.h"

class cUdp
{
private:
    static const U16 UDP_ANNOUNCE_PORT  = 7654;

    static const U8 UDP_SRC_PORT_H_P    = 0x22;
    static const U8 UDP_SRC_PORT_L_P    = 0x23;
    static const U8 UDP_DST_PORT_H_P    = 0x24;
    static const U8 UDP_DST_PORT_L_P    = 0x25;
    static const U8 UDP_LENGTH_H_P      = 0x26;
    static const U8 UDP_LENGTH_L_P      = 0x27;
    static const U8 UDP_CHECKSUM_H_P    = 0x28;
    static const U8 UDP_CHECKSUM_L_P    = 0x29;
    static const U8 UDP_DATA_P          = 0x2A;

public:
    static void GenerateUDPPacket ( U8 *pBuff, U16 iSrcPort, U16 iDestPort, U16 iLen );
    static bool UDPReceive ( U8 *pBuff, U8 *pDestMac, U8 *pDestIP );
    static bool SendPacket( U8* pBuff, U8* pDestMac, U8 *pDestIP, U16 iSrcPort, U16 iDestPort, U16 iLen);
    static U16 ProcessDataIncome(U8 *pData, U16 iLen);
};

#endif

